#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define N 20 
#define RANGE 10

int a[N];

void gen_random() {
    int i;
    for (i = 0; i < N; i++) {
        a[i] = rand() % RANGE;
    }
}

int count_frequency(int value) {
    int count = 0, i;
    for (i = 0; i < N; i++) {
        if (a[i] == value) {
            count++;
        }
    }
    return count;
}

void print_histogram() {
    int value;
    for (value = 0; value < RANGE; value++) {
        int freq = count_frequency(value);
        printf("%d: ", value);
        for (int i = 0; i < freq; i++) {
            printf("*");
        }
        printf(" （%d次）\n", freq);
    }
}

int main(void) {
    srand((unsigned int)time(NULL));
    
    gen_random();
    print_histogram();
    
    return 0;
}